<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>flash_helper.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../vesc.jpg"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="../../modules.html"><span>Modules</span></a></li>
      <li><a href="../../annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">flash_helper.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="../../d4/d1b/flash__helper_8h_source.html">flash_helper.h</a>&quot;</code><br />
<code>#include &quot;ch.h&quot;</code><br />
<code>#include &quot;hal.h&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d3/d26/stm32f4xx__conf_8h_source.html">stm32f4xx_conf.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d5/d60/utils_8h_source.html">utils.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d4/d38/mcpwm_8h_source.html">mcpwm.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../db/dae/hw_8h_source.html">hw.h</a>&quot;</code><br />
<code>#include &lt;string.h&gt;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a3e3bca0bf87643f04607022ece7b4b14"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a3e3bca0bf87643f04607022ece7b4b14">FLASH_SECTORS</a>&#160;&#160;&#160;12</td></tr>
<tr class="separator:a3e3bca0bf87643f04607022ece7b4b14"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad0198c5f6b8570629c6ce18fbcaa07b9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#ad0198c5f6b8570629c6ce18fbcaa07b9">BOOTLOADER_BASE</a>&#160;&#160;&#160;11</td></tr>
<tr class="separator:ad0198c5f6b8570629c6ce18fbcaa07b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6cf6a5f0042b93414d8c3039cd5540e3"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a6cf6a5f0042b93414d8c3039cd5540e3">APP_BASE</a>&#160;&#160;&#160;0</td></tr>
<tr class="separator:a6cf6a5f0042b93414d8c3039cd5540e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa1342082fc298d17435fd4d4ad1b1dcd"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#aa1342082fc298d17435fd4d4ad1b1dcd">NEW_APP_BASE</a>&#160;&#160;&#160;8</td></tr>
<tr class="separator:aa1342082fc298d17435fd4d4ad1b1dcd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa785ce84c6aff09267c84dbdaf03264d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#aa785ce84c6aff09267c84dbdaf03264d">NEW_APP_SECTORS</a>&#160;&#160;&#160;3</td></tr>
<tr class="separator:aa785ce84c6aff09267c84dbdaf03264d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a626254790c0810ff2dda356393e10c"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a1a626254790c0810ff2dda356393e10c">ADDR_FLASH_SECTOR_0</a>&#160;&#160;&#160;((uint32_t)0x08000000)</td></tr>
<tr class="separator:a1a626254790c0810ff2dda356393e10c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3921df9831b40afc489e0abb4ae2e1d8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a3921df9831b40afc489e0abb4ae2e1d8">ADDR_FLASH_SECTOR_1</a>&#160;&#160;&#160;((uint32_t)0x08004000)</td></tr>
<tr class="separator:a3921df9831b40afc489e0abb4ae2e1d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a252ab8bba2a5556d7aa70c4629749b25"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a252ab8bba2a5556d7aa70c4629749b25">ADDR_FLASH_SECTOR_2</a>&#160;&#160;&#160;((uint32_t)0x08008000)</td></tr>
<tr class="separator:a252ab8bba2a5556d7aa70c4629749b25"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a299b477f5a33428b1867eecc8663028a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a299b477f5a33428b1867eecc8663028a">ADDR_FLASH_SECTOR_3</a>&#160;&#160;&#160;((uint32_t)0x0800C000)</td></tr>
<tr class="separator:a299b477f5a33428b1867eecc8663028a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0137a47c6b41f7aef7e18d9bc280a918"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a0137a47c6b41f7aef7e18d9bc280a918">ADDR_FLASH_SECTOR_4</a>&#160;&#160;&#160;((uint32_t)0x08010000)</td></tr>
<tr class="separator:a0137a47c6b41f7aef7e18d9bc280a918"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6e78dc4f01c1faf00384490d3536f4de"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a6e78dc4f01c1faf00384490d3536f4de">ADDR_FLASH_SECTOR_5</a>&#160;&#160;&#160;((uint32_t)0x08020000)</td></tr>
<tr class="separator:a6e78dc4f01c1faf00384490d3536f4de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a353c96f72d9893b5c24e9775a6e9f999"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a353c96f72d9893b5c24e9775a6e9f999">ADDR_FLASH_SECTOR_6</a>&#160;&#160;&#160;((uint32_t)0x08040000)</td></tr>
<tr class="separator:a353c96f72d9893b5c24e9775a6e9f999"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0fcae367e68209cb20aec1f31d0cef75"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a0fcae367e68209cb20aec1f31d0cef75">ADDR_FLASH_SECTOR_7</a>&#160;&#160;&#160;((uint32_t)0x08060000)</td></tr>
<tr class="separator:a0fcae367e68209cb20aec1f31d0cef75"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a46efd249195dc6615a5f991bf67fbfd5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a46efd249195dc6615a5f991bf67fbfd5">ADDR_FLASH_SECTOR_8</a>&#160;&#160;&#160;((uint32_t)0x08080000)</td></tr>
<tr class="separator:a46efd249195dc6615a5f991bf67fbfd5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a94b661cf00ffc288e3d2983c3d6c72ed"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a94b661cf00ffc288e3d2983c3d6c72ed">ADDR_FLASH_SECTOR_9</a>&#160;&#160;&#160;((uint32_t)0x080A0000)</td></tr>
<tr class="separator:a94b661cf00ffc288e3d2983c3d6c72ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3cea1f00ae802317e67815c9dedc62b7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a3cea1f00ae802317e67815c9dedc62b7">ADDR_FLASH_SECTOR_10</a>&#160;&#160;&#160;((uint32_t)0x080C0000)</td></tr>
<tr class="separator:a3cea1f00ae802317e67815c9dedc62b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7b945836a10e9782cbb63338f271f2aa"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a7b945836a10e9782cbb63338f271f2aa">ADDR_FLASH_SECTOR_11</a>&#160;&#160;&#160;((uint32_t)0x080E0000)</td></tr>
<tr class="separator:a7b945836a10e9782cbb63338f271f2aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a4fe6e8165c1fa89d02c591180783d11f"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a4fe6e8165c1fa89d02c591180783d11f">flash_helper_erase_new_app</a> (uint32_t new_app_size)</td></tr>
<tr class="separator:a4fe6e8165c1fa89d02c591180783d11f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99c7831232016110d54d56d40224fb2d"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a99c7831232016110d54d56d40224fb2d">flash_helper_write_new_app_data</a> (uint32_t offset, uint8_t *data, uint32_t len)</td></tr>
<tr class="separator:a99c7831232016110d54d56d40224fb2d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a88237caea6b04b65b8c68802392cc88b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d72/flash__helper_8c.html#a88237caea6b04b65b8c68802392cc88b">flash_helper_jump_to_bootloader</a> (void)</td></tr>
<tr class="separator:a88237caea6b04b65b8c68802392cc88b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a1a626254790c0810ff2dda356393e10c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_0&#160;&#160;&#160;((uint32_t)0x08000000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3921df9831b40afc489e0abb4ae2e1d8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_1&#160;&#160;&#160;((uint32_t)0x08004000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3cea1f00ae802317e67815c9dedc62b7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_10&#160;&#160;&#160;((uint32_t)0x080C0000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a7b945836a10e9782cbb63338f271f2aa"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_11&#160;&#160;&#160;((uint32_t)0x080E0000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a252ab8bba2a5556d7aa70c4629749b25"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_2&#160;&#160;&#160;((uint32_t)0x08008000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a299b477f5a33428b1867eecc8663028a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_3&#160;&#160;&#160;((uint32_t)0x0800C000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a0137a47c6b41f7aef7e18d9bc280a918"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_4&#160;&#160;&#160;((uint32_t)0x08010000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6e78dc4f01c1faf00384490d3536f4de"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_5&#160;&#160;&#160;((uint32_t)0x08020000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a353c96f72d9893b5c24e9775a6e9f999"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_6&#160;&#160;&#160;((uint32_t)0x08040000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a0fcae367e68209cb20aec1f31d0cef75"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_7&#160;&#160;&#160;((uint32_t)0x08060000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a46efd249195dc6615a5f991bf67fbfd5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_8&#160;&#160;&#160;((uint32_t)0x08080000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a94b661cf00ffc288e3d2983c3d6c72ed"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ADDR_FLASH_SECTOR_9&#160;&#160;&#160;((uint32_t)0x080A0000)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6cf6a5f0042b93414d8c3039cd5540e3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define APP_BASE&#160;&#160;&#160;0</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="ad0198c5f6b8570629c6ce18fbcaa07b9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BOOTLOADER_BASE&#160;&#160;&#160;11</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3e3bca0bf87643f04607022ece7b4b14"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FLASH_SECTORS&#160;&#160;&#160;12</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="aa1342082fc298d17435fd4d4ad1b1dcd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define NEW_APP_BASE&#160;&#160;&#160;8</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="aa785ce84c6aff09267c84dbdaf03264d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define NEW_APP_SECTORS&#160;&#160;&#160;3</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a4fe6e8165c1fa89d02c591180783d11f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t flash_helper_erase_new_app </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>new_app_size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a88237caea6b04b65b8c68802392cc88b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void flash_helper_jump_to_bootloader </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Stop the system and jump to the bootloader. </p>

</div>
</div>
<a class="anchor" id="a99c7831232016110d54d56d40224fb2d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t flash_helper_write_new_app_data </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
</div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://github.com/joshdellay" target="_new">Josh Dellay</a>